package com.typy.www.tpay.ui.itemview;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.typy.www.tpay.R;
import com.typy.www.tpay.bean.vm.IcoTypeVm;
import com.typy.www.tpay.ui.acitivity.DigitalAssetsDetailActivity;
import com.typy.www.tpay.util.ClassHoldUtil;
import com.typy.www.tpay.util.UpdataUiUtil;
import com.zhy.android.percent.support.PercentLinearLayout;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by 13799 on 2018/6/28.
 */

public class IcotypeItemView {
    View mView;
    ViewHolder holder;
    private Context mContext;

    public IcotypeItemView(Context context) {
        mContext = context;
        mView = LayoutInflater.from(context).inflate(R.layout.item_icotype, null);
        holder = new ViewHolder(mView);
    }

    public View getView() {
        return mView;
    }

    public void bind(final IcoTypeVm vm, final int position, final int classType) {
        if (vm != null) {
            if (classType == ClassHoldUtil.DigitalAssets) {
                UpdataUiUtil.getDefaul().setText(vm.getFdName(), holder.tvName)
                        .setText(vm.getFdQuantity(), holder.tvZichan)
                        .setText(vm.getFdPrice(), holder.tvDangqianjiage)
                        .setText(vm.getFdName()+"资产(¥)",holder.tvTitle2);
            }
        }
        holder.llJiaoyi.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                DigitalAssetsDetailActivity.show(mContext, vm.getFdName(), vm.getFdSeqNo(), vm.getFdStartPrice(), vm.getFdEndPrice(), vm.getFdPrice() + "", vm.getFdId());
            }
        });
    }


    static class ViewHolder {
        @BindView(R.id.tv_name)
        TextView tvName;
        @BindView(R.id.tv_zichan)
        TextView tvZichan;
        @BindView(R.id.tv_title2)
        TextView tvTitle2;
        @BindView(R.id.ll_amount)
        PercentLinearLayout llAmount;
        @BindView(R.id.tv_dangqianjiage)
        TextView tvDangqianjiage;
        @BindView(R.id.ll_point)
        PercentLinearLayout llPoint;
        @BindView(R.id.ll_jiaoyi)
        LinearLayout llJiaoyi;
        @BindView(R.id.ll_root)
        PercentLinearLayout llRoot;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
